package zozopo.manual;

import java.util.Map;

import javax.servlet.RequestDispatcher;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.manual.operations.ContentImagesOS;
import zozopo.manual.operations.ContentImagesTB;
import zozopo.manual.operations.ContentOS;
import zozopo.manual.operations.ContentTB;
import zozopo.user.operations.UserTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class PreReleaseAction extends ActionSupport implements Action ,SessionAware{
	//输入
	private int contentId;
	private String title;
	private String context1;
	private String kind;
	private String cnbrand;
	private String enbrand;
	
	//输出
	ContentTB content;

	
	private Map<Object, Object> session;
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}

	public String execute(){

		UserTB user = (UserTB)session.get("userInfo");
		if(user == null){
		    return NONE;
			//跳转
		}
		
		ContentOS contentOS = new ContentOS();
		
		try{
			if(contentOS.isExitContent(contentId)){
				content = contentOS.get(contentId);
			}else{
				content = contentOS.getDraft(user.getId_user());
			}
						
		}finally{
			contentOS.releaseConnection();
		}
		
		contentId = content.getId();
		title = content.getTitle();
		kind = content.getKind();
		context1 = content.getContext();
		cnbrand = content.getCnbrand();
		enbrand = content.getEnbrand();
		
		return SUCCESS;
	}
	
	
	

	public int getContentId() {
		return contentId;
	}

	public void setContentId(int contentId) {
		this.contentId = contentId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContext1() {
		return context1;
	}

	public void setContext1(String context1) {
		this.context1 = context1;
	}

	public String getKind() {
		return kind;
	}

	public void setKind(String kind) {
		this.kind = kind;
	}

	public String getCnbrand() {
		return cnbrand;
	}

	public void setCnbrand(String cnbrand) {
		this.cnbrand = cnbrand;
	}

	public String getEnbrand() {
		return enbrand;
	}

	public void setEnbrand(String enbrand) {
		this.enbrand = enbrand;
	}

	public ContentTB getContent() {
		return content;
	}

	public void setContent(ContentTB content) {
		this.content = content;
	}

}
